<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">

    <meta content="telephone=yes,email=yes" name="format-detection">
    <!--//自动识别电话号码和邮箱-->

    <meta content="yes" name="apple-mobile-web-app-capable">
    <!--//苹果手机：会删除默认的工具栏和菜单栏，网站开启对web app程序的支持-->
    <meta name="apple-mobile-web-app-status-bar-style" content="default"/>
    <!--//苹果手机：在web app应用下状态条（屏幕顶部条）的颜色,默认值为default（白色），可以定为black（黑色）和black-translucent（灰色半透明）。-->
    <meta name="apple-touch-fullscreen" content="yes"/>
    <!--//苹果手机：如果把一个web app添加到了主屏幕中，那么从主屏幕中打开这个web app则全屏显示-->
    <link rel="apple-touch-icon" href="images/identity/HTML5_Badge_64.png"/>
    <!--//苹果手机：将应用添加到手机主屏幕，会有一个icon可以直接进入-->


    <title>有收入</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <!--初始化样式-->
    <link rel="stylesheet" href="css/reset.css">
    <!--共用样式-->
    <link rel="stylesheet" href="css/common.css">
    <!--整个网站的局部样式-->
    <link rel="stylesheet" href="css/style.css">
    <!--适配样式-->
    <link rel="stylesheet" href="css/styleMedia.css">
</head>

<body>

<!--header begin-->
<header>
    <div id="flexHeader">
        <div class="div1"></div>
        <div class="div2">登录</div>
        <div class="div3"></div>
    </div>
</header>
<!--header end-->
<br>
<!--login begin-->
<article class="clearfix login">
    <form action="" method="post">
        <div class="tel-login">
            <input type="search" id="userTel" value="18059786425" name="userTel" required="required" autocomplete="off" autofocus placeholder="请您输入手机登录账号" >
        </div>
        <div class="pwd-login">
            <input type="password" id="password" value="111111" placeholder="请您输入登录密码" >
        </div>
        <div class="info1" id="box2"></div>
        <div class="user-login-btn-selected" id="loginBtn">用户登录</div>
    </form>

    <div class="reg-forgettingPwd">
        <div class="reg"><a href="reg.html" id="regBtn">快速注册</a> </div>
        <div class="forgetPwd"><a href="forget.html">忘记密码?</a> </div>
    </div>

</article>
<!--login end-->

<!--js-->
<script src="js/jquery-1.12.3.min.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/common.js"></script>
<script src="js/config.js"></script>
<script>
	mui.plusReady(function(){
	 var token = plus.storage.getItem('token')
	 if(token){
		 $.ajax({
		 	url: $CONFIG.baseUrl+"/api/autoLogin",
		 	type: 'post',
		 	data: {
		 		token: token
		 	},
		 	success: function(data){
		 		if(data.code===200){
		 			plus.storage.setItem("token",data.data.token)
		 			plus.storage.setItem("user",JSON.stringify(data.data.user))
		 			mui.openWindow({
		 			url: 'index.html',
		 			id: 'index'
		 			})
		 		}
		 	},
		 	error: function(error){
		 		
		 	}
		 })
	 }
	 
     $('#regBtn').click(function(){
		 // console.log('reg')
     	mui.openWindow({
     		url: 'reg.html',
     		id: 'reg'
     	})
     })
	 $('#loginBtn').click(function(){
		 $.ajax({
			 url: $CONFIG.baseUrl+'/doLogin/1',
			 type:'post',
			 data: {
				 phone: $('#userTel').val(),
				 password: $('#password').val()
			 },
			 success:function(data){
				 if(data.code===200){
					 plus.storage.setItem("token",data.data.token)
					 plus.storage.setItem("user",JSON.stringify(data.data.user))
					 mui.openWindow({
					 	url: 'index.html',
					 	id: 'index'
					 })
				 }else{
					 alert(data.msg)
				 }
			 },
			 error: function(error){
			 		console.log("ssssss")
				 console.log(error)
			 }
		 })
	 })
	});
</script>
</body>
</html>